<template>
	<view class="content">
		<z-paging ref="paging" v-model="formList" @query="get_form_list" :default-page-size="20">
			<template slot="top">
				<view class="bartop"></view>
				<view class="cu-bar">
					<view class="action">
						<text class="cuIcon-back text-gray" @tap="goBack"></text> 返回
					</view>
					<view class="text-lg text-bold">
						报表填报管理
					</view>
					<view class="action">
						<text class="text-lg" style="color: #13227a;" @tap="createForm">新建</text>
					</view>
				</view>
			</template>

			<view v-if="formList.length>0" class="cu-list menu">
				<view v-for="(item,index) in formList" :key="index" @click="showDetail(item)" class="cu-item"
					:style="index%2==0?'background:#fff':'background:#dedede' ">
					<view class="item margin-top-sm">
						<text>订单号：{{item.orderId}}</text>
						<text>产品名称：{{item.productName}}</text>
					</view>
					<view class="item margin-bottom-sm">
						<text>机台编号：{{item.numberName}} </text>
						<text>操作工：{{item.operatorName}}</text>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// "id": null, // id
				// "class": null, //班次
				// "order_id": null, //订单号
				// "product_id": null, //产品名称
				// "number": null, //机台编号
				// "unit": null, //单位
				// "material_id": null, //用料
				// "colour_id": null, //颜色/色粉
				// "order_number": null, //排产数量
				// "qualified_quantity": null, //生产合格数量
				// "working_hours": null, //实际生产工时
				// "scrapped_part": null, //残品数量
				// "operator": null, //操作工
				// "accumulate_number": null, //合格累计数量
				// "debugging_time": null, //换模调试时间
				// "change_material_time": null, // 换料烘料时间
				// "weight": null, //产品单重
				// "abnormal_time": null, //其他异常事件
				// "remarks": null, //备注
				formList: []
			}
		},
		methods: {

			onShow() {
				this.$refs.paging.reload()
			},

			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			get_form_list(pageNo, pageSize) {
				this.$Request.post(this.$httpApi.form.list + "?page=" + pageNo + "&size=" + pageSize).then(res => {
					if (res.code != 200) {
						uni.showToast({
							title: res.message,
							icon: 'none',
							duration: 2000
						});
					} else {
						console.log(res)
						try {
							uni.hideLoading()
							this.$refs.paging.complete(res.data.list)
						} catch (e) {
							this.$refs.paging.complete([])
							uni.hideLoading()
						}
					}
				})
			},

			showDetail(item) {
				uni.navigateTo({
					url: '/pages/form_detail/form_detail?id=' + item.id + "&operator=" + item.operatorName +
						"&productName=" + item.productName
				})
			},

			createForm() {
				uni.navigateTo({
					url: '/pages/report_form/report_form'
				})
			}
		}
	}
</script>

<style>
	.cu-list.menu>.cu-item {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.item {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
</style>
